package cn.qqncn.furniture.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
 * @author zkw
 * @ClassName ResultUtils.java
 * @Description TODO
 * @createTime 2020年12月27日 23:14:00
 */
public class ResultUtils {
    private static ObjectMapper objectMapper = new ObjectMapper();

    /**
     * 返回值封装
     * @param i sql执行成功条数
     * @return
     * @throws JsonProcessingException
     */
    public static String result(int i) throws JsonProcessingException {
        ObjectNode objectNode = objectMapper.createObjectNode();
        if (i > 0) {
            objectNode.put("code", "00000");
            return objectMapper.writeValueAsString(objectNode);
        } else {
            objectNode.put("code", "B0001");
            return objectMapper.writeValueAsString(objectNode);
        }
    }
}
